package com.jgsu.farm.mapper.sql;

import com.jgsu.farm.entity.Image;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Repository
public interface ImageMapperSql {
    @Insert("insert into image(name,format,description,author,time,location,device,imageFile) values(#{name},#{format},#{description},#{author},#{time},#{location},#{device},#{imagefile})")
    @Options(useGeneratedKeys = true,keyProperty = "imageid",keyColumn = "imageID")
    void insert(Image image);

    @Delete("delete from image where imageID = #{imageid}")
    void delete(Integer imageid);

    @Update("update image set Name = #{name},format = #{format},description = #{description},author = #{author},description = #{description},time = #{time},location = #{location},device = #{device},imageFile = #{imagefile} where imageID = #{imageid}")
    void update(Image image);

    @Select("select * from image where imageID = #{imageid}")
    Image select(Integer imageid);

    @Select("select imageFile from image where imageID = #{imageid}")
    String selectImageFileById(Integer imageid);

}
